import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Home.vue'),
    children : [
      {
        path: '/Find',
        name: 'Find',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/Find.vue')
      },
      {
        path: '/Blog',
        name: 'Blog',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/Blog.vue')
      },
      {
        path: '/Follow',
        name: 'Follow',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/Follow.vue')
      },
      {
        path: '/My',
        name: 'My',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/My.vue')
      },
      {
        path: '/Seach',
        name: 'Seach',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/Seach.vue'),
        children : [
          {
            path : '/Seach/Vocalist',
            name : 'Vocalist',
            component: () => import(/* webpackChunkName: "about" */ '../views/Vocalist.vue'),
          },
          {
            path : '/Seach/SeachList',
            name : 'SeachList',
            component: () => import(/* webpackChunkName: "about" */ '../views/SeachList.vue'),
          },
          {
            path : '/Seach/SongList',
            name : 'SeachList',
            component: () => import(/* webpackChunkName: "about" */ '../views/Songmenu.vue'),
          }
        ],
        redirect:'/Seach/Vocalist'
      },
      {
        path : '/Singer',
        name : 'SeachList',
        component: () => import(/* webpackChunkName: "about" */ '../views/Singer-view.vue')
      },
      {
        path : '/SingerIndex',
        name : 'SingerIndex',
        component: () => import(/* webpackChunkName: "about" */ '../views/SingerIndex.vue')
      }
    ],
    redirect:'/Find',
  }
]

const router = new VueRouter({
  routes,
  linkActiveClass :'active'
})

//防止重复路由
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
export default router
